﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Linq;
using System.Configuration;
using System.Data.SqlClient;

namespace DAL
{
    public class Connect
    {
        public static T GetDataContext<T>() where T : DataContext, new()
        {
            T t = new T();
            try
            {
                t.Connection.ConnectionString = ConfigurationManager.ConnectionStrings["Strconnect"].ConnectionString;
                //t.ObjectTrackingEnabled = false;
                return t;
            }
            catch
            {
                return null;
            }
        }

        public static T GetDataContext<T>(string s) where T : DataContext, new()
        {
            T t = new T();
            try
            {
                t.Connection.ConnectionString = ConfigurationManager.ConnectionStrings[s].ConnectionString;
                //t.ObjectTrackingEnabled = false;
                return t;
            }
            catch
            {
                return null;
            }
        }
        public static string NoteWranglerConnectionString
        {
            get
            {
                string connectionString = ConfigurationManager.ConnectionStrings["Strconnect"].ConnectionString;
                return connectionString;
            }
        }

        public static SqlConnection GetNoteWranglerConnection()
        {
            return new SqlConnection(NoteWranglerConnectionString);
        }

    }
}